import smtplib
from email.mime.text import MIMEText


def send_qqemail(messages, subject, sender_email, sender_password, rec_email):
    """

    :return:
    """
    msg = MIMEText(messages)
    msg['Subject'] = subject
    msg['From'] = sender_email
    msg['To'] = rec_email

    with smtplib.SMTP_SSL('smtp.qq.com', 465) as smtp:
        smtp.login(sender_email, sender_password)
        smtp.send_message(msg)
        print("发送完毕")


def main():
    email_info = {"messages": "乖乖是傻瓜",
                  "subject": "傻瓜",
                  "sender_email": "lilenzhi@qq.com",
                  "rec_email": "llz15565161793@163.com",
                  "sender_password": 'fcgpxfqboraleeej'}

    send_qqemail(**email_info)


if __name__ == '__main__':
    n = 10
    while n:
        n -= 1
        main()
